package com.dzpk.facadeserver.net;

import com.dzpk.facadeserver.processer.GetGameIpProcesser;
import com.dzpk.localprotocol.CyAppStruct;
import org.apache.mina.core.session.IoSession;
import somnus.net.message.IMessage;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by somnus on 16/8/22.
 */
public class Dispatcher {
    private static Map<Integer, Processer> processerMap = new HashMap<>();

    static{
        processerMap.put(CyAppStruct.MSG.REQ_GET_GAME_IP_VALUE, new GetGameIpProcesser());
    }


    public static void dispatch(IoSession session,IMessage message) throws Exception{
        Processer processer = processerMap.get(message.getId());
        if(processer == null){
            return;
        }
        processer.process(session, message.getData());
    }
}
